package com.doudizu.shoesonline.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.doudizu.shoesonline.mapper.LinkMapper;
import com.doudizu.shoesonline.model.dto.link.LinkQuery;
import com.doudizu.shoesonline.model.entity.Link;
import com.doudizu.shoesonline.service.LinkService;
import org.springframework.stereotype.Service;


/**
* @description 针对表【link(链接)】的数据库操作Service实现
* @createDate 2023-07-03 09:55:30
*/
@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link>
    implements LinkService {

    @Override
    public Object getLinks(LinkQuery linkQuery) {
        Integer pageNum = linkQuery.getPageNum();
        Integer pageSize = linkQuery.getPageSize();
        //TODO 可选分页
        if (pageNum==null || pageSize==null){
            pageNum=1;
            pageSize=5;
        }
        Page<Link> objectPage = new Page<>(pageNum, pageSize);
        QueryWrapper<Link> brandQueryWrapper = new QueryWrapper<>();
        brandQueryWrapper.eq("type",1);
        brandQueryWrapper.like(linkQuery.getLinkName() != null,"link_name",linkQuery.getLinkName());
        Page<Link> page = this.page(objectPage, brandQueryWrapper);
        return page;
    }
}




